<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: column_top.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$uri = explode('.', basename($_SERVER['PHP_SELF']));
$uri = $uri[0];

function getActiveTopMenu($mid) {
	$activeID = (isset($_GET['menu']) ? $_GET['menu'] : '').(isset($_POST['menu']) ? $_POST['menu'] : '');
	if($mid == $activeID)
		return ' top_link_active';
	else
		return '';
}

function getMenuItems($parent_id = '0', $group) {
	global $db;

	$getMenuLinks = $db->db_query("SELECT DISTINCT
										acm.mID,
										acm.menu_name,
										acm.group_id,
										acm.parent_id,
										acm.visible,
										acm.sort_order,
										acm.link,
										acm.title_language_id_".$_SESSION['languages_id']."
									FROM
										".TABLE_ADMIN_MENU." acm,
										 ".TABLE_ADMIN_ACCESS_RIGHTS." aar
									WHERE 
										(((acm.menu_name = aar.file_name OR aar.file_name LIKE CONCAT(acm.menu_name,'-',acm.group_id)) AND acm.link = '1' AND aar.".$group." = '1')
										OR 
										acm.link = '0')
									AND	
										acm.visible = '1'
									AND
										acm.parent_id = '".$parent_id."'
									ORDER BY
										acm.sort_order ASC ");
	$menu = '';
	if($parent_id == 0)
		$menu .= '<ul id="top_menu" class="menu">';		
	else
		$menu .= '<ul>';
																
	while(!$getMenuLinks->EOF) {
		
		if($getMenuLinks->fields['link'] == '0' && $parent_id > 0) {
			$menu .= '	<li>
							<span class="sub_menu_head">
								<b>'.$getMenuLinks->fields['title_language_id_'.$_SESSION['languages_id']].'</b>
							</span>';
			$menu .= 		getMenuItems($getMenuLinks->fields['mID'], $group);
			$menu .= '	</li>';
			
		} elseif($getMenuLinks->fields['link'] == '0' && $parent_id == 0) {
			$menu .= '	<li>';
			$menu .= '		<a class="top_link'.getActiveTopMenu($getMenuLinks->fields['mID']).'" href="javascript:void(0)">
								<span>'.$getMenuLinks->fields['title_language_id_'.$_SESSION['languages_id']].'</span>
							</a>';
			$menu .= 		getMenuItems($getMenuLinks->fields['mID'], $group);
			$menu .= '	</li>';
			
		} elseif($getMenuLinks->fields['link'] == '1') {
			$menu .= '	<li>';
			$menu .= '		<a'.$a_class.' href="'.$getMenuLinks->fields['menu_name'].'.php?menu='.$parent_id.(!empty($getMenuLinks->fields['group_id']) ? '&gID='.$getMenuLinks->fields['group_id']:'').'">
								<span>'.$getMenuLinks->fields['title_language_id_'.$_SESSION['languages_id']].'</span>
							</a>';
			$menu .= 		getMenuItems($getMenuLinks->fields['mID'], $group);
			$menu .= '	</li>';
		}
		
		$getMenuLinks->MoveNext();
	}
	$menu .= '</ul>';
	return $menu;
}
?>
<table width="100%" class="outerTable top_table">
	<tr>
		<td>
			<?php
				echo getMenuItems(0, 'g_'.$_SESSION['customers_status']['customers_admin_id']);
			?>
			<script type="text/javascript">
				$(function(){$('#top_menu').menu().fadeIn(800);});
			</script>
		</td>
		<td width="10" align="right">
			<img class="xajax_spinner" src="images/spinner.gif" alt="bitte warten..." />
		</td>
		<td width="1" align="right">
			<form name="search" id="search" action="global_search.php" method="POST">
				<div style="position: relative">
					<input type="text" name="search" value="" size="30" class="mag_text" />
					<input type="image" src="images/icons/magnifier-left.png" value="" class="mag" />
				</div>
		    </form>
		</td>
	</tr>
</table>
<link rel="stylesheet" type="text/css" href="includes/javascript/growl/jquery.gritter.css" />
<script type="text/javascript" src="includes/javascript/growl/jquery.gritter.min.js"></script>
<?php if($message_stack->size > 0) { ?>
<script type="text/javascript">
	$(function(){
		<?php echo $message_stack->output(); ?>
	});
</script>
<?php } ?>